/**
 * Created by liubin on 2017/2/23.
 */

var WhmjTableMsgStatus = function () {

    var that = {};
    that.useTing = false;
    that.useTingKouNums = [];

    that.sendPlayCard = function(cardNum){
        if (that.getMyIsPlayCard){
            var cardNums = [cardNum];
            if (that.useTing){
                that.sendLiangTingCard(cardNums, that.useTingKouNums);
            } else{
                var actionRequest = 8;
                //如果打出的牌是单杠的牌
                if (mo.whmjCardHelper.getIsSingCard(cardNum)){
                    actionRequest = 7;
                }

                mo.gameMsgManager.sendActionRequestwhmj(actionRequest, cardNums, []);
            }
        }
    };


    that.sendOpenCard = function(actionRequestwhmj){
        mo.gameMsgManager.sendActionRequestwhmj(actionRequestwhmj.code, actionRequestwhmj.Cards1, []);
    };

    //cardNum 用户打出的废牌    kouCards 用户扣的牌 去掉重复22 22 22 为22
    that.sendLiangTingCard = function (cardNums, kouCards) {
        mo.gameMsgManager.sendActionRequestwhmj(0, cardNums, kouCards);

        cc.log("扣牌:" + kouCards.toString() + "扣牌长度是:" + kouCards.length);
    };

    //返回自己是否可以出牌
    that.getMyIsPlayCard = function(){
        if (that.mTableStatus.IsPlayCard){
            var seatUser = that.mTableStatus["SeatUser" + that.mTableStatus.MySeat];
            for (var i = 0; i < seatUser.NewActionList.length; i++){
                if (seatUser.NewActionList[i].code == 8){
                    return true;
                }
            }
        }

        return false;
    };


    return that;
};